package control;
import library.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

@SuppressWarnings("unused")
public class dbtest{
	
	 public static void main(String args[]) {

		 Connection conn = null;
		 DatabaseConnect db = new DatabaseConnect();
         try{
            /* String userName = "root";
             String password = "root";
             String url = "jdbc:mysql://10.4.23.16/anves";
             Class.forName ("com.mysql.jdbc.Driver").newInstance ();
             conn = DriverManager.getConnection (url, userName, password);
             System.out.println ("Database connection established");*/
        	 conn = db.connect();
         }catch (Exception e){
             System.err.println ("Cannot connect to database server");
         }finally{
             if (conn != null){
                 try {
                	 Statement s = conn.createStatement ();
                	   //SELECT TypBezeichnung FROM anhaengertyp
                	   s.executeQuery ("SELECT * FROM anhaengertyp");
                	   //s.executeQuery ("SELECT AdressNummer FROM ADRESSE");
                	   ResultSet rs = s.getResultSet ();
                	   int count=0;
                	   //AdressNummer
                	   while (rs.next ()){
                	       Object idVal = rs.getString ("anhaengertypnummer");
                	       System.out.println ("id = " + idVal);
                	       ++count;
                	   }
                	   rs.close ();
                	   s.close ();
                	   db.DatabaseClose(conn);
                    
                 }catch (Exception e) { 
                	 /* ignore close errors */ 
                	 System.out.println(e);
                 }
             }
         }
	 }	 
}